import { reactive, ref } from 'vue';

// 全局共享的消息列表与计数
export const messages = reactive([]);
export const msgCount = ref(0);

// 外部调用方法：推送消息
export function pushMessage({ title, desc, date, tag = 'success', type = '订单', route = null }) {
  messages.unshift({ title, desc, date, tag, type, route });
  msgCount.value = messages.length;
}

export function markAllRead() {
  msgCount.value = 0;
}

export function clearAll() {
  messages.splice(0, messages.length);
  msgCount.value = 0;
}


